﻿using Scommesse.Model;
using Scommesse.Persistence;
using Scommesse.View;
using Scommesse.View.Admin;

namespace Scommesse.Presenters.Admin
{
    public class AdminFormPresenter : IAdminFormPresenter
    {
        private readonly AdminForm _adminForm;
        private readonly InserimentoTessera _insForm;

        public AdminFormPresenter(AutenticazioneTessera autForm, InserimentoTessera insForm)
        {
            _insForm = insForm;
            autForm.Close();
            _adminForm = new AdminForm();
            _adminForm.AddListener(this);
            _adminForm.Show();
        }

        #region IAdminFormController Members

        public void LoadEventoDialog()
        {
            new EventoPresenter(new EventoDialog());
        }

        public void LoadEliminaEventoDialog()
        {
            new EliminaEventoPresenter(new EliminaDialog());
        }

        public void LoadCategoriaDialog()
        {
            new CategoriaPresenter(new CategoriaDialog());
        }

        public void LoadEliminaCategoriaDialog()
        {
            new EliminaCategoriaPresenter(new EliminaDialog());
        }

        public void LoadCompetizioneDialog()
        {
            new CompetizionePresenter(new CompetizioneDialog());
        }

        public void LoadEliminaCompetizioneDialog()
        {
            new EliminaCompetizionePresenter(new EliminaDialog());
        }

        public void LoadRisultatoDialog()
        {
            new RisultatoPresenter(new RisultatoDialog());
        }

        public void LoadConfermaDialog()
        {
            var conferma = new ConfermaDialog();
            conferma.AddListener(this);
            conferma.ShowDialog();
        }

        public void ChiudiProgrammaESalva()
        {
            DataSaver.SavePalinsestoOnFile(Palinsesto.GetPalinsesto());
            _insForm.Show();
            _insForm.Activate();
        }

        public void ChiudiProgramma()
        {
            _insForm.Show();
            _insForm.Activate();
        }

        #endregion
    }
}